package com.teamwork.shareplatform.service.impl;

import com.github.pagehelper.PageHelper;
import com.teamwork.shareplatform.entity.User;
import com.teamwork.shareplatform.mapper.UserMapper;
import com.teamwork.shareplatform.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class UserServiceImpl implements UserService {
    @Resource
    UserMapper userMapper;

    @Override
    public List<User> findAll() {
        return userMapper.findAll();
    }

    @Override
    public User checkUser(String telephone, String password,int utype) {
        return userMapper.findBylogin(telephone,password,utype);
    }

    @Override
    public int addUser(User user) {
        return userMapper.addUser(user);
    }

    @Override
    public User queryById(int uid) {
        return userMapper.queryById(uid);
    }

    @Override
    public List<User> queryAllUser(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return userMapper.queryAllUser();
    }

    @Override
    public int addUserByEdit(User user) {
        return userMapper.addUserByEdit(user);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public int deleteUser(int id) {
        return userMapper.deleteUser(id);
    }

}